#include "sNamedObject.h"

namespace sgui
{

// --------------------------------- sNamedObject -------------------------------------

sNamedObject::sNamedObject(sGUI& gui, const std::wstring& name) : 
	sGUIObject(gui),
	m_name(name)
{
        
}

const std::wstring& sNamedObject::getName() const
{
    return m_name;
}

void sNamedObject::save(db::Record& file) const
{
    file.setName(getName());
	sGUIObject::save(file);
}
	
void sNamedObject::load(const db::Record& file)
{
	sGUIObject::load(file);
}
    
void sNamedObject::updateName(const std::wstring& name)
{
    m_name = name;
}

void sNamedObject::setName(const std::wstring& name)
{
    if (name == m_name) return;
    if (name.empty()) return;
	notify(new obs::sChangeNameEvent(m_name, name));
}

#ifdef _EDITOR
	void sNamedObject::exportRTTI(rtti::sInfoList& list)
	{
		REGISTER_RTTI(L"Name", TEXT, NEW_RTTI_PARAMETER(
			STRING, sNamedObject, this, &sNamedObject::setName, &sNamedObject::getName
		));
	}
#endif

sNamedObject::~sNamedObject()
{
    
}

};